package demo1;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Test {
    public static List<List<Integer>> generate(int nub){
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> list = new ArrayList<>();
        list.add(1);
        ret.add(list);
        for (int i = 1; i < nub; i++) {
            List<Integer> curList = new ArrayList<>();
            curList.add(1);
            //处理中间数字
            List<Integer> preList = ret.get(i - 1);
            for (int j = 1; j < i; j++) {
                int val = preList.get(j) + preList.get(j - 1);
                curList.add(val);
            }
            curList.add(1);
            ret.add(curList);
        }
        return ret;

    }

    public static void main(String[] args) {
        generate(5);

    }
    public static void func(String str1,String str2){
        List<Character> ret = new ArrayList<>();
        for (int i = 0;i < str1.length();i++){
            char ch = str1.charAt(i);
            if(!str2.contains(ch +"")){
                ret.add(ch);
            }
        }
        System.out.println(ret);
    }

    public static void main3(String[] args) {
        func("welcom to bit","come");
    }
    public static void func1(String str1,String str2){
        ArrayList<Character> arrayList = new ArrayList<>();
        for (int i = 0 ;i < str1.length();i++){
            char ch  = str1.charAt(i);
            if(!str2.contains(ch +"")){
                arrayList.add(ch);
            }
        }
        System.out.println(arrayList);
    }

    public static void main2(String[] args) {
        String str1 = "welcom to bit";
        String str2 = "come";
        func1(str1,str2);
    }
    public static void main1(String[] args) {
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add("111");
        arrayList.add("abc");
        arrayList.add("def");
        arrayList.add("ghf");
        arrayList.add("hhh");
        List<String> ret = arrayList.subList(1,3);
        System.out.println(ret);
        //ArrayList的三种遍历
        System.out.println(arrayList);
        System.out.println();
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.print(arrayList.get(i)+"   ");

        }
        System.out.println();

        for (String x:arrayList) {
            System.out.print(x+"   ");
        }
        System.out.println();

        Iterator<String> it = arrayList.listIterator();
        while ((it.hasNext())){
            System.out.println(it.next()+"  ");
        }
//        System.out.println(arrayList);
//        System.out.println("====");
//        for (int i = 0; i < arrayList.size(); i++) {
//            System.out.print(arrayList.get(i) + "    ");
//        }
//        System.out.println("=====");
//        for (String x: arrayList) {
//            System.out.print(x+"    ");
//        }
//
//        Iterator<String> it = arrayList.listIterator();
//        while(it.hasNext()){
//            System.out.print(it.next() + "  ");
//        }
//        System.out.println(  );
    }
}
